/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * <p>Project: javase - TreeMapTest
 * <p>Powered by webrx On 2021-12-21 16:37:23
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class TreeMapTest {
    public static void main(String[] args) {
        //key降序 ，如果构造方法中没有参数是，key升序
        //Map<String, Integer> maps = new TreeMap<>(Comparator.reverseOrder());

        //默认是升序
        Map<String, Integer> maps = new TreeMap<>();
        maps.put("张三", 22);
        maps.put("李四", 24);
        maps.put("王五", 18);
        maps.put("赵六", 28);
        maps.put("张三丰", 32);
        maps.put("李丽", 21);
        System.out.println(maps);

        BiConsumer<String, Integer> bc = (a, b) -> System.out.printf("姓名：%s,年龄：%d岁。%n", a, b);
        bc.accept("李四", 28);


        bc.accept("张三", 18);
    }
}
